import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import type {RouteRecordRaw} from "vue-router"
const routes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "login",
    meta: { title: "登录页" },
    component: () => import('@/views/login/index.vue'),
},
  // {
  //   path: '/',
  //   redirect: '/index',
  // },
  {
    path: '',
    name: 'home',
    component: () => import('@/views/HomeView.vue'),
    redirect: 'login',
    children:[
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index/index.vue'),
      },
      {
        path: '/detail',
        name: 'detail',
        component: () => import('@/views/index/detail.vue'),
      }
    ]
  },
]
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
})

router.beforeEach((to, from, next) => {
  next();
})

export default router
